import request from '@/utils/request'

export async function getList(data) {
  return request({
    url: '/role/getRoleList',
    method: 'post',
    data,
  })
}

export function getRoles() {
  return request({
    url: '/role/getRoleList',
    method: 'post',
    data: {},
  })
}

export async function doDelete(id) {
  return request({
    url: '/role/deleteById?id=' + id,
    method: 'post',
    data: {},
  })
}

export async function addRole(data) {
  return request({
    url: '/role/addRole',
    method: 'post',
    data,
  })
}

export async function editRole(data) {
  return request({
    url: '/role/updateRole',
    method: 'post',
    data,
  })
}
export async function assignRole(params) {
  return request({
    url: '/user/assignRole',
    method: 'post',
    data: params,
  })
}
export function getRolesById(userId) {
  return request({
    url: '/role/queryListByUserId?userId=' + userId,
    method: 'post',
    data: {},
  })
}
// 修改角色状态
export function setRoleEnable(id, isEnable) {
  return request({
    url: '/role/setRoleEnable',
    method: 'post',
    data: { id, isEnable },
  })
}
